/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.yourorghere;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

/**
 *
 * @author henriquediomede
 */
public class Keyboard implements KeyListener
{
    
    public Keyboard()
    {
        key = new int[4];
        for(int i = 0; i < key.length; i++)
            key[i] = 0;
    }
    
  
    public static int[] getInput()
    {
        return key;
    }
    

    public void keyTyped(KeyEvent ke) 
    {
        
    }

    public void keyPressed(KeyEvent ke) 
    {
        switch(ke.getKeyCode())
        {
            case KeyEvent.VK_RIGHT:
               key[0] = 1;
                break;
                
            case KeyEvent.VK_LEFT:
                key[1] = 1;
                break;
                
            case KeyEvent.VK_UP:
                key[2] = 1;
                break;
                
            case KeyEvent.VK_DOWN:
                key[3] = 1;
                break;
        }
    }

    public void keyReleased(KeyEvent ke) 
    {
         switch(ke.getKeyCode())
        {
            case KeyEvent.VK_RIGHT:
               key[0] = 0;
                break;
                
            case KeyEvent.VK_LEFT:
                key[1] = 0;
                break;
                
            case KeyEvent.VK_UP:
                key[2] = 0;
                break;
                
            case KeyEvent.VK_DOWN:
                key[3] = 0;
                break;
        }
    }
    
    private static int key[];
}
